function getHighScore() {
	$.get('UpdateHighscore', function (tulemus) {
		var names = new Array();
		var wins = new Array();
		var stringArray = tulemus.split(",");
		for (var i = 0; i < stringArray.length; i += 2) {
			names.push(stringArray[i]);
			wins.push(stringArray[i+1]);
		}
		
		clearHighScoreTable();
		addRows("edeTabeliTabel", names, wins);
		fadeIn('edeTabel');
	});
}

function clearHighScoreTable() {
	var table = document.getElementById('edeTabeliTabel');
	for(var i = 2; i < table.rows.length; i += 1) {
		table.deleteRow(i);
		i -= 1;
	}
}

function addRows(ID, namesArray, winsArray) {
	var table = document.getElementById(ID);
	for (var i = 0; i < namesArray.length; i += 1) {
		var row = document.createElement("tr");
		var name = document.createElement("td");
		var win = document.createElement("td");
		name.innerHTML = namesArray[i];
		win.innerHTML = winsArray[i];
		row.appendChild(name);
		row.appendChild(win);
		table.appendChild(row);
	}
}